{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "2002be3d",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "15d39da7",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>No</th>\n",
       "      <th>Name</th>\n",
       "      <th>Age</th>\n",
       "      <th>Class</th>\n",
       "      <th>Section</th>\n",
       "      <th>Phone number</th>\n",
       "      <th>location</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>11</td>\n",
       "      <td>Abdullah</td>\n",
       "      <td>20</td>\n",
       "      <td>12</td>\n",
       "      <td>Ghouri</td>\n",
       "      <td>300300003</td>\n",
       "      <td>multan</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>ali</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>Ghouri</td>\n",
       "      <td>300300003</td>\n",
       "      <td>multan</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>omer</td>\n",
       "      <td>13</td>\n",
       "      <td>12</td>\n",
       "      <td>Ghouri</td>\n",
       "      <td>300300003</td>\n",
       "      <td>multan</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   No      Name  Age  Class Section  Phone number location\n",
       "0  11  Abdullah   20     12  Ghouri     300300003   multan\n",
       "1   2       ali   12     12  Ghouri     300300003   multan\n",
       "2   3      omer   13     12  Ghouri     300300003   multan"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pandas.read_csv(\"pandas.csv\")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "b0804deb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>No</th>\n",
       "      <th>Name</th>\n",
       "      <th>Age</th>\n",
       "      <th>Class</th>\n",
       "      <th>Section</th>\n",
       "      <th>Phone number</th>\n",
       "      <th>location</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>11</td>\n",
       "      <td>Abdullah</td>\n",
       "      <td>20</td>\n",
       "      <td>12</td>\n",
       "      <td>Ghouri</td>\n",
       "      <td>300300003</td>\n",
       "      <td>multan</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>ali</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>Ghouri</td>\n",
       "      <td>300300003</td>\n",
       "      <td>multan</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>omer</td>\n",
       "      <td>13</td>\n",
       "      <td>12</td>\n",
       "      <td>Ghouri</td>\n",
       "      <td>300300003</td>\n",
       "      <td>multan</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   No      Name  Age  Class Section  Phone number location\n",
       "0  11  Abdullah   20     12  Ghouri     300300003   multan\n",
       "1   2       ali   12     12  Ghouri     300300003   multan\n",
       "2   3      omer   13     12  Ghouri     300300003   multan"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.index = [0,1,2]\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "f28230cc",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\ABDULL~1\\AppData\\Local\\Temp/ipykernel_4136/1782505548.py:1: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  df['No'][0] = 1\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>No</th>\n",
       "      <th>Name</th>\n",
       "      <th>Age</th>\n",
       "      <th>Class</th>\n",
       "      <th>Section</th>\n",
       "      <th>Phone number</th>\n",
       "      <th>location</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Abdullah</td>\n",
       "      <td>20</td>\n",
       "      <td>12</td>\n",
       "      <td>Ghouri</td>\n",
       "      <td>300300003</td>\n",
       "      <td>multan</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>ali</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>Ghouri</td>\n",
       "      <td>300300003</td>\n",
       "      <td>multan</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>omer</td>\n",
       "      <td>13</td>\n",
       "      <td>12</td>\n",
       "      <td>Ghouri</td>\n",
       "      <td>300300003</td>\n",
       "      <td>multan</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   No      Name  Age  Class Section  Phone number location\n",
       "0   1  Abdullah   20     12  Ghouri     300300003   multan\n",
       "1   2       ali   12     12  Ghouri     300300003   multan\n",
       "2   3      omer   13     12  Ghouri     300300003   multan"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['No'][0] = 1\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "8880d322",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>Age</th>\n",
       "      <th>Class</th>\n",
       "      <th>Section</th>\n",
       "      <th>Phone number</th>\n",
       "      <th>location</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>No</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Abdullah</td>\n",
       "      <td>20</td>\n",
       "      <td>12</td>\n",
       "      <td>Ghouri</td>\n",
       "      <td>300300003</td>\n",
       "      <td>multan</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>ali</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>Ghouri</td>\n",
       "      <td>300300003</td>\n",
       "      <td>multan</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>omer</td>\n",
       "      <td>13</td>\n",
       "      <td>12</td>\n",
       "      <td>Ghouri</td>\n",
       "      <td>300300003</td>\n",
       "      <td>multan</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        Name  Age  Class Section  Phone number location\n",
       "No                                                     \n",
       "1   Abdullah   20     12  Ghouri     300300003   multan\n",
       "2        ali   12     12  Ghouri     300300003   multan\n",
       "3       omer   13     12  Ghouri     300300003   multan"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.set_index(\"No\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "cb5b197f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Age</th>\n",
       "      <th>Class</th>\n",
       "      <th>Section</th>\n",
       "      <th>Phone number</th>\n",
       "      <th>location</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>Ghouri</td>\n",
       "      <td>300300003</td>\n",
       "      <td>multan</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>13</td>\n",
       "      <td>12</td>\n",
       "      <td>Ghouri</td>\n",
       "      <td>300300003</td>\n",
       "      <td>multan</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Age  Class Section  Phone number location\n",
       "1   12     12  Ghouri     300300003   multan\n",
       "2   13     12  Ghouri     300300003   multan"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# Let suppose i want to acces the index 1 to 2 and colum Age to location\n",
    "df.loc[1:3,\"Age\":\"location\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "d67107ed",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>No</th>\n",
       "      <th>Name</th>\n",
       "      <th>Age</th>\n",
       "      <th>Class</th>\n",
       "      <th>Section</th>\n",
       "      <th>Phone number</th>\n",
       "      <th>location</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Abdullah</td>\n",
       "      <td>20</td>\n",
       "      <td>12</td>\n",
       "      <td>Ghouri</td>\n",
       "      <td>300300003</td>\n",
       "      <td>multan</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>ali</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>Ghouri</td>\n",
       "      <td>300300003</td>\n",
       "      <td>multan</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>omer</td>\n",
       "      <td>13</td>\n",
       "      <td>12</td>\n",
       "      <td>Ghouri</td>\n",
       "      <td>300300003</td>\n",
       "      <td>multan</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   No      Name  Age  Class Section  Phone number location\n",
       "0   1  Abdullah   20     12  Ghouri     300300003   multan\n",
       "1   2       ali   12     12  Ghouri     300300003   multan\n",
       "2   3      omer   13     12  Ghouri     300300003   multan"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "90a877b1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>Age</th>\n",
       "      <th>Class</th>\n",
       "      <th>Section</th>\n",
       "      <th>Phone number</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>ali</td>\n",
       "      <td>12</td>\n",
       "      <td>12</td>\n",
       "      <td>Ghouri</td>\n",
       "      <td>300300003</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>omer</td>\n",
       "      <td>13</td>\n",
       "      <td>12</td>\n",
       "      <td>Ghouri</td>\n",
       "      <td>300300003</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Name  Age  Class Section  Phone number\n",
       "1   ali   12     12  Ghouri     300300003\n",
       "2  omer   13     12  Ghouri     300300003"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[1:3,1:6]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "11aebe46",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
